<template>
    <swiper class="categoryList" :autoplay="true" :circular="true" :indicator-dots="false" indicator-color="rgba(228,228,228,1)" indicator-active-color="#FECA49">
        <swiper-item v-for="(b,i) in banner" :key="i"  @click='bannerlink(b)'>
          <a class="category-info">
            <img :src="b.picture">
          </a>
        </swiper-item>
  </swiper>
</template>

<script>
  import ajax from '@/utils/ajax'
export default {
  data() {
    return {
      banner:[],
    }
  },
  methods: {
    bannerlink: function(banner){
      if(banner.status!=1){
        return false
      }
      if(banner.id==290){
        if (!sessionStorage.getItem('isLogin')) {
          Toast('请先登录')
          this.$router.push('/login')
          return false
        }
        this.$router.push({
          path: '/friend',
          query: {
            m: sessionStorage.getItem('account')
          }
        })
      }else{
        if(banner.url){
          let url = banner.url.split("#")[1]
          console.log(url)
          this.$router.push("/pages/fuli"+url)
        }
      }
    },
  },
  mounted(){
      let $this = this
      ajax.request('/wap/banner_list.html',{
        id:56
      },function (res) {
        console.log(res.data)
        if(res.code==0) {
          $this.banner = res.data
        }
      })
      /*this.$http.post('/wap/banner_list.html',{id:56}).then((res)=>{
        //输出请求数据
        console.log(res.data)
        //输出响应头
        console.log(res.header)
      }).catch(err=>{
        console.log(err.status,err.message)
      })*/
  }
}
</script>

<style lang="stylus" scoped>
    .categoryList
        width 100%
        height 330rpx
        /*border-bottom 20rpx solid #f4f4f4*/
        .category-info
            display inline-block
            text-align center
            position relative
            width 100%
            height 330rpx
            image
              width 100%
              height 100%



</style>
